using System;
using System.Collections.Generic;

namespace PokerStar.Core.Rules
{
    public class CardNumberComparer : IComparer<char>
    {
        public int Compare(char a, char b)
        {
            return Card2Int(a) - Card2Int(b);
        }

        public static int Card2Int(char number)
        {
            if (number >= '2' && number <= '9')
                return number - '0';

            switch (number)
            {
                case 'T':
                    return 10;
                case 'J':
                    return 11;
                case 'Q':
                    return 12;
                case 'K':
                    return 13;
                case 'A':
                    return 14;
                default:
                    throw new InvalidCastException("unknown number -> " + number);
            }
        }
    }
}